package wuaipojie

import (
	"errors"
	"fmt"
	"github.com/imroc/req/v3"
)

type ErrReq struct {
	HTTPStatusCode int
	Raw            []byte
	Err            error
}

func NewErrReq(resp *req.Response, err error) *ErrReq {
	return &ErrReq{
		HTTPStatusCode: resp.StatusCode,
		Raw:            resp.Bytes(),
		Err:            err,
	}
}

func (e *ErrReq) Error() string {
	return e.Err.Error()
}

func (e *ErrReq) Unwrap() error {
	return e.Err
}

type ErrLogin struct {
	Msg string `xml:",cdata"`
}

func (e *ErrLogin) Error() string {
	return e.Msg
}

type ErrWAFZWVerify string

func (e ErrWAFZWVerify) Error() string {
	return string(e)
}

type ErrNeedVerifyWaf struct {
	LZ        string
	LJ        string
	LE        string
	UserAgent string
}

func (e *ErrNeedVerifyWaf) Error() string {
	return fmt.Sprintf("need verify waf, LZ: %s, LJ: %s, LE: %s", e.LZ, e.LJ, e.LE)
}

var ErrNeedLogin = errors.New("need login")

type ErrCheck string

func (e ErrCheck) Error() string {
	return string(e)
}
